<?php

/*
 * litchicms
 * Copyright (C) 2010-7-10 Author: tiefa(539247@qq.com)
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

if (!function_exists('Component_ui_viewtpl')) {

    function Component_ui_viewtpl($arr=FALSE) {
        !$arr && exit('Component_ui_viewtpl');
        $input = input_text_control('viewtpl', $arr['collection_value'], 'viewtpl', "text", "input_text", "150");
        return "
    <div class='content_group_row'>
        <table border='0' cellpadding='0' cellspacing='1' class='thetable'>
                <tr>
                    <td class='td1'>
                        <div>
                            <div class='cname'><b>内容模板</b>:</div>
                            <div class='cdesc'>如果为空则使用继承的模板...</div>
                        </div>
                    </td>
                    <td class='td2'>
                        <div>
                        $input
                        </div>
                    </td>
                </tr>
        </table>
    </div>
    ";
    }

}

$BRK_GLOBAL['ComponentValidationFunction'][] = 'Component_field_viewtpl';

if (!function_exists('Component_field_viewtpl')) {

    function Component_field_viewtpl() {
        !key_exists('viewtpl', $_POST['field']) && exit("KEY viewtpl IS NOT EXISTS IN ARRAY \$_POST['field']");

        if (empty($_POST['field']['viewtpl'])) {
            $_POST['field']['viewtpl']="";
        }

        return TRUE;
    }

}